<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>欢迎页面-L-admin1.0</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" href="../css/font.css">
  <link rel="stylesheet" href="../css/xadmin.css">
  <script src="../js/jquery.min.js"></script>
  <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
  <script type="text/javascript" src="../js/xadmin.js"></script>
 <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">查看试卷</a>
        <a>
          <cite>查看试卷</cite></a>
      </span>
  <a class="layui-btn layui-btn-primary layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:38px">ဂ</i></a>
</div>
<div class="x-body">
  <div class="layui-row">
    <form class="layui-form layui-col-md12 x-so">
      <input type="text" name="teaNo"  placeholder="请输入试卷编号" id="teaNo" autocomplete="off" class="layui-input" style="width: 160px;">
      <input type="button" class="layui-btn" lay-submit="" lay-filter="search" id="searchByNo" value="搜索"
             onclick="searchTeaByNo()"/>
      <input type="text" name="teaName"  placeholder="请输入试卷名称" id="teaName" autocomplete="off" class="layui-input">
      <input type="button" class="layui-btn" lay-submit="" lay-filter="search" id="searchByName" value="搜索"
             onclick="searchTeaByName()"/>
      <input type="text" name="teaDl"  placeholder="请输入试卷类型" id="teaDl" autocomplete="off" class="layui-input" style="width: 160px;">
      <input type="button" class="layui-btn" lay-submit="" lay-filter="search" id="searchByDis" value="搜索"
             onclick="searchTeaByDl()"/>
      <br><br>
      <input type="button" class="layui-btn" id="showAll" onclick="showAllTea()" value="查看所有"/>
    </form>
  </div>
  <xblock>
    <span class="x-left" style="line-height:40px">本次搜索总共搜索到<b><font size="4px" color="red" id="number">这里填入搜索结果的统计数量</font></b>条数据</span>
  </xblock>
  <table class="layui-table">
    <thead >
    <tr>
      <th>试卷编号</th>
      <th>试卷名称</th>
      <th>试卷创立时间</th>
      <th>试卷类型</th>
      <th>试卷题目数量</th>
      <th>试卷难易程度</th>
      <th>试卷满分</th>
      <th width="8%">查看试卷详情</th>
    </tr>
    </thead>
    <tbody id="testList">
    <tr id="test"></tr>
    <td class="td-manage" id="button"></td>
    <td id="芜湖"></td>
    <tr id="test0">
      <td id="testNo0"></td>
      <td id="testName0"></td>
      <td id="testTime0"></td>
      <td id="testType0"></td>
      <td id="testNum0"></td>
      <td id="testDif0"></td>
      <td id="testScore0"></td>
      <td class="td-manage" id="button0">
        <a title="查看" id="查看" onclick="x_admin_show_sendId(this.title,'testDetails.html')" href="javascript:;">
          <button class="layui-btn layui-btn-fluid">查看试卷</button>
        </a>
      </td>
    </tr>
    </tbody>
  </table>

  <input id="Id" type="hidden" name="tstNo" value="">

</div>
<script>
  layui.use('laydate', function(){
    var laydate = layui.laydate;

    //执行一个laydate实例
    laydate.render({
      elem: '#start' //指定元素
    });

    //执行一个laydate实例
    laydate.render({
      elem: '#end' //指定元素
    });
  });
</script>

<script type="text/javascript">
    $.ajax({
        url: "/exam/queryall",
        type : "post",
        async: false,
        dataType: "json",
        data :null,
        // contentType: "application/json",
        success: function (data) {
            console.log("请求成功");
            console.log(data);
            var i=0;
            var Test;
            for (;;i++){
                if (data[i]){
                    if (i!==0){
                    console.log(data[i]);
                    console.log(i);
                    var test=document.getElementById("test").cloneNode(true);

                    var tstNo=document.getElementById("testNo0").cloneNode(true);
                    var tstName=document.getElementById("testName0").cloneNode(true);
                    var tstTime=document.getElementById("testTime0").cloneNode(true);
                    var tstType=document.getElementById("testType0").cloneNode(true);
                    var tstNum=document.getElementById("testNum0").cloneNode(true);
                    var tstDif=document.getElementById("testDif0").cloneNode(true);
                    var tstScore=document.getElementById("testScore0").cloneNode(true);

                    tstNo.innerHTML=data[i].tstNo;
                    tstName.innerHTML=data[i].tstName;
                    tstTime.innerHTML=data[i].tstTime;
                    tstType.innerHTML=data[i].tstType;
                    tstNum.innerHTML=data[i].tstNum;
                    tstDif.innerHTML=data[i].tstDif;
                    tstScore.innerHTML=data[i].tstScore;

                    test.appendChild(tstNo);
                    test.appendChild(tstName);
                    test.appendChild(tstTime);
                    test.appendChild(tstType);
                    test.appendChild(tstNum);
                    test.appendChild(tstDif);
                    test.appendChild(tstScore);
                    var button=document.getElementById("button").cloneNode(true);
                    var button0=document.getElementById("查看").cloneNode(true);
                    button0.title=data[i].tstNo;
                    button.appendChild(button0);
                    test.appendChild(button);

                    document.getElementById("testList").appendChild(test);
                    var j=i+1;
                    document.getElementById("number").innerHTML=j;
                    }
                    else if (i==0){
                      document.getElementById("查看").title=data[0].tstNo;
                        document.getElementById("testNo0").innerHTML=data[0].tstNo;
                        document.getElementById("testName0").innerHTML=data[0].tstName;
                        document.getElementById("testTime0").innerHTML=data[0].tstTime;
                        document.getElementById("testType0").innerHTML=data[0].tstType;
                        document.getElementById("testNum0").innerHTML=data[0].tstNum;
                        document.getElementById("testDif0").innerHTML=data[0].tstDif;
                        document.getElementById("testScore0").innerHTML=data[0].tstScore;
                    }
                }
                else break;
            }
        },
        error: function (data) {
            console.log("请求失败");
        }
    });
</script>

<script type="text/javascript">
function search(){
  var start=document.getElementById("start").innerText;
  var end=document.getElementById("end").innerText;
  var dif=$("#dif").val();
  var testNo=$("#testNo").val();
  var testName=document.getElementById("testName").innerText;
  var testType=document.getElementById("testType").innerText;
  console.log(testNo);
  if (dif!==""){
    var j=1;
    var i=j.toString();
    console.log(i);
    $.ajax({
      url: "/exam/querybytstno",
      type : "post",
      async: false,
      dataType: "json",
      data :{ tstNo: testNo},
      // contentType: "application/json",
      success: function (data) {
        console.log("请求成功");
        console.log(data);
       var test=document.createElement("test1");
        var tstNo=document.createElement("testNo"+i);
        var tstName=document.createElement("tstName"+i);
        var tstTime=document.createElement("tstTime"+i);
        var tstType=document.createElement("tstType"+i);
        var tstDetail=document.createElement("tstDetail"+i);
        var tstNum=document.createElement("tstNum"+i);
        var tstDif=document.createElement("tstDif"+i);
        var tstScore=document.createElement("tstScore"+i);

        document.getElementsByName("test1")[0].setAttribute("id","test1");
        document.getElementsByName("tstNo"+i)[0].setAttribute("id","tstNo"+i);
        document.getElementsByName("tstName"+i)[0].setAttribute("id","tstName"+i);
        document.getElementsByName("tstTime"+i)[0].setAttribute("id","tstTime"+i);
        document.getElementsByName("tstType"+i)[0].setAttribute("id","tstType"+i);
        document.getElementsByName("tstDetail"+i)[0].setAttribute("id","tstDetail"+i);
        document.getElementsByName("tstNum"+i)[0].setAttribute("id","tstNum"+i);
        document.getElementsByName("tstDif"+i)[0].setAttribute("id","tstDif"+i);
        document.getElementsByName("tstScore"+i)[0].setAttribute("id","tstScore"+i);

        document.getElementById("tstNo"+i).innerHTML=data.tstNo;
        document.getElementById("tstName"+i).innerHTML=data.tstName;
        document.getElementById("tstTime"+i).innerHTML=data.tstTime;
        document.getElementById("tstType"+i).innerHTML=data.tstType;
        document.getElementById("tstDetail"+i).innerHTML=data.tstDetail;
        document.getElementById("tstNum"+i).innerHTML=data.tstNum;
        document.getElementById("tstDif"+i).innerHTML=data.tstDif;
        document.getElementById("tstScore"+i).innerHTML=data.tstScore;

        document.getElementById("test"+i).appendChild(tstNo);
        document.getElementById("test"+i).appendChild(tstName);
        document.getElementById("test"+i).appendChild(tstTime);
        document.getElementById("test"+i).appendChild(tstType);
        document.getElementById("test"+i).appendChild(tstDetail);
        document.getElementById("test"+i).appendChild(tstNum);
        document.getElementById("test"+i).appendChild(tstDif);
        document.getElementById("test"+i).appendChild(tstScore);

        document.getElementById("testList").appendChild(test);

        return;
      },
      error: function (data) {
        console.log("请求失败");

        return;
      }
    });
  }
  else {
      $.ajax({
          url: "/exam/queryall",
          type : "post",
          async: false,
          dataType: "json",
          data :{ tstNo: testNo},
          // contentType: "application/json",
          success: function (data) {
              console.log("请求成功");
              console.log(data);
              var test=document.createElement("test1");
              var tstNo=document.createElement("testNo"+i);
              var tstName=document.createElement("tstName"+i);
              var tstTime=document.createElement("tstTime"+i);
              var tstType=document.createElement("tstType"+i);
              var tstDetail=document.createElement("tstDetail"+i);
              var tstNum=document.createElement("tstNum"+i);
              var tstDif=document.createElement("tstDif"+i);
              var tstScore=document.createElement("tstScore"+i);

              document.getElementsByName("test1")[0].setAttribute("id","test1");
              document.getElementsByName("tstNo"+i)[0].setAttribute("id","tstNo"+i);
              document.getElementsByName("tstName"+i)[0].setAttribute("id","tstName"+i);
              document.getElementsByName("tstTime"+i)[0].setAttribute("id","tstTime"+i);
              document.getElementsByName("tstType"+i)[0].setAttribute("id","tstType"+i);
              document.getElementsByName("tstDetail"+i)[0].setAttribute("id","tstDetail"+i);
              document.getElementsByName("tstNum"+i)[0].setAttribute("id","tstNum"+i);
              document.getElementsByName("tstDif"+i)[0].setAttribute("id","tstDif"+i);
              document.getElementsByName("tstScore"+i)[0].setAttribute("id","tstScore"+i);

              document.getElementById("tstNo"+i).innerHTML=data.tstNo;
              document.getElementById("tstName"+i).innerHTML=data.tstName;
              document.getElementById("tstTime"+i).innerHTML=data.tstTime;
              document.getElementById("tstType"+i).innerHTML=data.tstType;
              document.getElementById("tstDetail"+i).innerHTML=data.tstDetail;
              document.getElementById("tstNum"+i).innerHTML=data.tstNum;
              document.getElementById("tstDif"+i).innerHTML=data.tstDif;
              document.getElementById("tstScore"+i).innerHTML=data.tstScore;

              document.getElementById("test"+i).appendChild(tstNo);
              document.getElementById("test"+i).appendChild(tstName);
              document.getElementById("test"+i).appendChild(tstTime);
              document.getElementById("test"+i).appendChild(tstType);
              document.getElementById("test"+i).appendChild(tstDetail);
              document.getElementById("test"+i).appendChild(tstNum);
              document.getElementById("test"+i).appendChild(tstDif);
              document.getElementById("test"+i).appendChild(tstScore);

              document.getElementById("testList").appendChild(test);

              return;
          },
          error: function (data) {
              console.log("请求失败");

              return;
          }
      });
  }
}
</script>

</body>

</html>